package com.yinhai.service;

import java.util.List;
import java.util.Map;

import com.yinhai.dao.IMGroupDaoImpl;
import com.yinhai.model.IMGroup;

import android.content.Context;

public class IMGroupServiceImpl {

	private Context context;
	private IMGroupDaoImpl imgroupDao;
	public IMGroupServiceImpl(Context context) {
		this.context = context;
		imgroupDao = new IMGroupDaoImpl(context);
	}
	
	/**
	 * 查询分组
	 * @return
	 */
	public List<Map<String,String>> getGroup() {
		String sql = "select group_id id,group_name name,user_phone from im_group";
		//String sql = "select im_p.group_id as id,im_p.group_name as name, im_p.user_phone as user_phone,im_u.user_name  as username from im_group as im_p  , im_user_group_test as im_u  where  im_p.group_id=im_u.group_id  ";
		return imgroupDao.query2MapList(sql, null);
//		List<Map<String,String>> list = new ArrayList<Map<String,String>>();
//		Map<String,String> map = new HashMap<String,String>();
//		map.put("group_id", "1");
//		map.put("group_name", "重庆公司");
//		map.put("user_phone", "");
//		return list;
	}
	public List<Map<String,String>> getGroupNew() {
		String sql = "select group_id,group_name from im_group";
		return imgroupDao.query2MapList(sql, null);
	}
	public void insert(IMGroup group) {
		imgroupDao.insert(group);
	}
	public void delete(String groupId) {
		String sql = "delete from im_group where group_id='"+groupId+"'";
		imgroupDao.execSql(sql, null);
	}
	
	public List<Map<String,String>> getGroup(String groupId) {
		String sql = "select group_id id,group_name name,user_phone from im_group where group_id='"+groupId+"'";
		return imgroupDao.query2MapList(sql, null);
	}
	
}
